package com.chris.homecare.utils
{
	import feathers.data.ListCollection;
	import feathers.system.DeviceCapabilities;
	
	import starling.core.Starling;

	public class CommonUtils
	{
		public static var scaleValue:Number;
		
		public static var eventCurrentMonth:int;
		public static var eventCurrentYear:int;
		public static var eventCurrentDate:Date;
		
		public static var previousScreen:String;
		
		public static var userEmail:String = "";
		public static var reviewHeading:String;
		
		public static var patientListCollection:ListCollection;
		
		public function CommonUtils()
		{
			initializeScale();
		}
		
		protected function initializeScale():void
		{
			var scaledDPI:int = DeviceCapabilities.dpi / Starling.contentScaleFactor;
			var originalDPI:int = scaledDPI;
			if(DeviceCapabilities.isTablet(Starling.current.nativeStage))
			{
				originalDPI = 264;
			}
			else
			{
				originalDPI = 326;
			}
			scaleValue = scaledDPI / originalDPI;
		}
		
		
		public static function isValidUserEmail(email:String):Boolean 
		{
			var myRegExp:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
			var myResult:Object = myRegExp.exec(email);
			if (myResult == null) 
			{
				return false;
			}
			return true;
		}
		
		public static function isValidPhoneNumber(phoneNumber:String):Boolean
		{
			var countryCode:String  = "((\\+|00)?([1-9]|[1-9][0-9]|[1-9][0-9]{2}))";
			var num:String      = "([0-9]{3,10})";
			phoneNumber = phoneNumber.match(/[\+\d]/g).join('');
			var phone:RegExp = new RegExp("^" + countryCode + num +"$");
			
			return phone.test(phoneNumber);
		}
	}
}